#!/usr/bin/env python
#  -*-coding:utf8 -*-
 
import rospy
from std_msgs.msg import String
from hellobot_msgs.msg import msg_battery

def CheckBattery():
    # 1 is charging
    # 0 is not charging
    IsCharging = False

    # remaining capacity
    Status = 70

    return(IsCharging, Status)


class BatteryStatus():
    def __init__(self):
        self.pub = rospy.Publisher('Battery', msg_battery, queue_size=10)
        rate = rospy.Rate(10)

        msg = msg_battery()
        while not rospy.is_shutdown():
            IsCharging, Status =  CheckBattery()
            msg.status = IsCharging
            msg.remain = Status 
            self.pub.publish(msg)
            #rospy.loginfo(msg)
            rate.sleep()


if __name__ == '__main__':
    rospy.init_node('BatteryStatus')
    try:
        BatteryStatus()
    except rospy.ROSInterruptException:
        pass
    rospy.spin()
